from selenium import webdriver
# 导入显式等待
from selenium.webdriver.support.wait import WebDriverWait
# 导入expected_conditions并起别名
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

# 打开浏览器,请求网址
driver = webdriver.Chrome()
driver.get('https://www.baidu.com')

# 定位搜索框标签 - 显式等待
# *('id', 'kw')  ==  By.ID, 'kw'
locator = ('id', 'kw')
kw = WebDriverWait(driver, 5).until(EC.presence_of_element_located(locator))
print(kw.get_attribute('outerHTML'))


# 星号*拆包
tuple1 = (By.ID, 'kw')
list1 = [By.ID, 'kw']
kw1 = driver.find_element(*tuple1)
kw2 = driver.find_element(*list1)
print(kw1.get_attribute('outerHTML'))
print(kw2.get_attribute('outerHTML'))


driver.quit()
